package com.smzd.ccms.business;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.smzd.ccms.dao.CompletConfigDao;
import com.smzd.ccms.domain.Complet;
import com.smzd.ccms.domain.CompletConfig;
import com.smzd.core.dao.IDao;
import com.smzd.framework.core.business.AbstractFGService;
import com.smzd.framework.utils.db.FGRowConverter;

@Service
public class CompletConfigService extends AbstractFGService<CompletConfig> {
    @Autowired
    private CompletConfigDao dao;
    
    @Override
    protected IDao<CompletConfig> getDao() {
        return dao;
    }
    
    @Override
    public FGRowConverter<CompletConfig> getConverter() {
        return converter;
    }

    private static FGRowConverter<CompletConfig> converter = new FGRowConverter<CompletConfig>() {
        @Override
        public Object[] convert(CompletConfig elem) {
            Complet complet = elem.getComplet();
            Object[] obj_complet;
            if(complet==null){
                obj_complet = null;
            }else{
                Integer id_complet = complet.getId();
                String name_complet = complet.getName();
                obj_complet = new Object[]{id_complet, name_complet};
            }
            Object[] fs = new Object[]{
                    elem.getId(),
                    elem.getName(),
                    elem.getDescription(),
                    elem.getSpotid(),
                    obj_complet
                };
                return fs;
        }
    };
}